package com.caregiver.watch.business.user.enums;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

/**
 * 设备在线状态枚举
 */
@Getter
@Schema(description = "设备在线状态枚举")
public enum DeviceOnlineStatusEnum {
    
    /**
     * 在线
     */
    @Schema(description = "在线")
    ONLINE("online", "在线"),
    
    /**
     * 离线
     */
    @Schema(description = "离线")
    OFFLINE("offline", "离线");

    private final String code;

    private final String description;

    DeviceOnlineStatusEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }


    /**
     * 根据描述获取枚举
     * @param onlineStatus 在线状态
     * @return DeviceOnlineStatusEnum
     */
    public static DeviceOnlineStatusEnum parse(String onlineStatus) {
        for (DeviceOnlineStatusEnum status : DeviceOnlineStatusEnum.values()) {
            if (status.getCode().equals(onlineStatus)) {
                return status;
            }
        }
        return OFFLINE;
    }
}
